package com.example.myapplication.scroller;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.myapplication.databinding.ActivityCustomScrollerBinding;

public class ScrollerActivity extends AppCompatActivity {


    ActivityCustomScrollerBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityCustomScrollerBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initEvent();
    }

    private void initEvent() {
        binding.btn1.setOnClickListener(v -> binding.customScrollerLayout.smoothScrollBy(200, 0,1000));
        binding.btn2.setOnClickListener(v -> binding.customScrollerLayout.smoothScrollBy(-200, 0,1000));
        binding.btn3.setOnClickListener(v -> binding.customScrollerLayout.smoothScrollTo(0, 0));
        binding.btn4.setOnClickListener(v -> binding.customScrollerLayout.smoothScrollBy(1500,0,2000));
    }
}
